package com.jiayang.hhotel.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.jiayang.hhotel.R;
import com.jiayang.hhotel.bean.AgreeGuestDetailsModel;
import com.jiayang.hhotel.util.StringUtil;

import java.util.List;

/**
 * Created by Administrator on 2017/5/24 0024.
 * 协议客户详情数据列表适配器
 */

public class AgreeGuestDetailsAdapter extends BaseAdapter{

    private Context t;
    private List<AgreeGuestDetailsModel.PTaMainListDtoBean> mList;
    private String[] titleList;
    public AgreeGuestDetailsAdapter(Context context, List<AgreeGuestDetailsModel.PTaMainListDtoBean> list){
        this.t=context;
        this.mList=list;
        this.titleList=t.getResources().getStringArray(R.array.agree_guest_details_data_title_list);
    }

    @Override
    public int getCount() {
        return titleList.length;
    }

    @Override
    public Object getItem(int position) {
        return 0;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    ViewHolder holder;
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if(convertView==null){
            convertView= LayoutInflater.from(t).inflate(R.layout.agree_guest_details_item,null);
            holder=new ViewHolder(convertView);
            convertView.setTag(holder);
        }
        holder= (ViewHolder) convertView.getTag();
        setText(holder,mList.get(0),position);
        return convertView;
    }

    public class ViewHolder{
        TextView tvFlag;//文字
        TextView tvContent;//内容

        public ViewHolder(View view){
            tvFlag= (TextView) view.findViewById(R.id.tv_title);
            tvContent= (TextView) view.findViewById(R.id.tv_content);
        }
    }

    private void setText(ViewHolder holder,AgreeGuestDetailsModel.PTaMainListDtoBean model,int pos){
        holder.tvFlag.setText(titleList[pos]);
        switch (pos){
            case 0://中文 名称
                holder.tvContent.setText(!StringUtil.isEmpty(model.getChnName())?model.getChnName():"");
                break;
            case 1://英文名称
                holder.tvContent.setText(!StringUtil.isEmpty(model.getEngName())?model.getChnName():"");
                break;
            case 2://类型
                holder.tvContent.setText(!StringUtil.isEmpty(model.getTaOrCompany()+"")?model.getChnName():"");
                break;
            case 3://协议类型
                holder.tvContent.setText(!StringUtil.isEmpty(model.getTaType())?model.getChnName():"");
                break;
            case 4://地址
                holder.tvContent.setText(!StringUtil.isEmpty(model.getAddr())?model.getChnName():"");
                break;
            case 5://邮编
                holder.tvContent.setText(!StringUtil.isEmpty(model.getZip())?model.getChnName():"");
                break;
            case 6://电话
                holder.tvContent.setText(!StringUtil.isEmpty(model.getPhone())?model.getChnName():"");
                break;
            case 7://传真
                holder.tvContent.setText(!StringUtil.isEmpty(model.getFax())?model.getChnName():"");
                break;
            case 8://网址
                holder.tvContent.setText(!StringUtil.isEmpty(model.getWebAddr())?model.getChnName():"");
                break;
            case 9://重要日期
                holder.tvContent.setText(!StringUtil.isEmpty(model.getFeteDay())?model.getChnName():"");
                break;
            case 10://开户银行
                holder.tvContent.setText(!StringUtil.isEmpty(model.getBank())?model.getChnName():"");
                break;
            case 11://银行账号
                holder.tvContent.setText(!StringUtil.isEmpty(model.getBankId())?model.getChnName():"");
                break;
            case 12://销售员
                holder.tvContent.setText(!StringUtil.isEmpty(model.getSalername())?model.getChnName():"");
                break;
            case 13://重要程度
                holder.tvContent.setText(!StringUtil.isEmpty(model.getImportance()+"")?model.getChnName():"");
                break;
            case 14://行业
                holder.tvContent.setText(!StringUtil.isEmpty(model.getIndustryType())?model.getChnName():"");
                break;
            case 15://市场
                holder.tvContent.setText(!StringUtil.isEmpty(model.getMarketCode())?model.getChnName():"");
                break;
            case 16://地区
                holder.tvContent.setText(!StringUtil.isEmpty(model.getArea())?model.getChnName():"");
                break;
            case 17://国籍
                holder.tvContent.setText(!StringUtil.isEmpty(model.getNation())?model.getChnName():"");
                break;
            case 18://集团协议客户账号
                holder.tvContent.setText(!StringUtil.isEmpty(model.getGrpTaAcct()+"")?model.getChnName():"");
                break;
            case 19://应收账号
                holder.tvContent.setText(!StringUtil.isEmpty(model.getArAcct()+"")?model.getChnName():"");
                break;
            case 20://团会公付可自动转应收
                holder.tvContent.setText(!StringUtil.isEmpty(model.getGrpTxToAr()+"")?model.getChnName():"");
                break;
            case 21://散客公付可自动转应收
                holder.tvContent.setText(!StringUtil.isEmpty(model.getGstTxToAr()+"")?model.getChnName():"");
                break;
            case 22://房价代码
                holder.tvContent.setText(!StringUtil.isEmpty(model.getRateCode())?model.getChnName():"");
                break;
            case 23://付款方式
                holder.tvContent.setText(!StringUtil.isEmpty(model.getPayment())?model.getChnName():"");
                break;
            case 24://建立日期
                holder.tvContent.setText(!StringUtil.isEmpty(model.getOrgDate())?model.getChnName():"");
                break;
            case 25://建立时间
                holder.tvContent.setText(!StringUtil.isEmpty(model.getOrgTime())?model.getChnName():"");
                break;
            case 26://建立人
                holder.tvContent.setText(!StringUtil.isEmpty(model.getOrgname())?model.getChnName():"");
                break;
            case 27://状态
                holder.tvContent.setText(!StringUtil.isEmpty(model.getStatus()+"")?model.getChnName():"");
                break;
            case 28://账号
                holder.tvContent.setText(!StringUtil.isEmpty(model.getAcct()+"")?model.getChnName():"");
                break;
//            case 29://
//                holder.tvContent.setText(!StringUtil.isEmpty(model.getChnName())?model.getChnName():"");
//                break;
//            case 30://
//                holder.tvContent.setText(!StringUtil.isEmpty(model.getChnName())?model.getChnName():"");
//                break;
//            case 31://
//                holder.tvContent.setText(!StringUtil.isEmpty(model.getChnName())?model.getChnName():"");
//                break;
//            case 32://
//                holder.tvContent.setText(!StringUtil.isEmpty(model.getChnName())?model.getChnName():"");
//                break;
//            case 33://
//                holder.tvContent.setText(!StringUtil.isEmpty(model.getChnName())?model.getChnName():"");
//                break;
//            case 34://
//                holder.tvContent.setText(!StringUtil.isEmpty(model.getChnName())?model.getChnName():"");
//                break;
        }
    }

}
